package com.yhsoft.buyer.controller;


import com.yhsoft.buyer.service.OrderReportService;
import com.yhsoft.common.service.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@Slf4j
@Api(tags = "用户订单导出")
@RequestMapping("/buyer")
public class OrderReportController {
    @Autowired
    private OrderReportService orderReportService;

    //导出订单列表
    @GetMapping("/ListExport")
    @ApiOperation("订单列表报表")
    public void ListExport(@RequestParam(value = "vendorId", required = false) Integer vendorId, HttpServletResponse response) throws IOException {
        if (vendorId == null) {
            vendorId = TokenService.getUserBytoken().getCompanyId();
        }
        orderReportService.OrderListReport(response, vendorId);
    }


    //供货商消耗日对账表
    @GetMapping("/LogExport")
    @ApiOperation("预存款消耗日志报表")
    public void YckLog(HttpServletResponse response) throws IOException {
        orderReportService.LogReport(response);
    }
}
